a<-c(1:3)
b<-c(2:4)

c<-(a&b)

a<-3.812

x<-round(a)

x <- matrix(4:15, nrow = 3,byrow = FALSE)

m <- matrix(1:6, ncol = 3, nrow = 2)




y <- c(12, 15, 18, 20, 22, 25)
mean_value <- mean(y)
median_value <- median(y)
sd_value <- sd(y)
var_value <- var(y)
max_value <- max(y)
min_value <- min(y)
print(paste("平均值：", mean_value))
print(paste("中位数：", median_value))
print(paste("标准差：", sd_value))
print(paste("方差：", var_value))
print(paste("最大值：", max_value))
print(paste("最小值：", min_value))



m <- matrix(1:9, nrow = 3, ncol = 3)
selected_elements <- m[1:2, c(1, 3)]
print(selected_elements)




my_array <- array(1:60, dim = c(4, 5, 3))

rownames(my_array[,,1]) <- c('R1', 'R2', 'R3', 'R4')
rownames(my_array[,,2]) <- c('R1', 'R2', 'R3', 'R4')
rownames(my_array[,,3]) <- c('R1', 'R2', 'R3', 'R4')

colnames(my_array[,,1]) <- c('C1', 'C2', 'C3', 'C4', 'C5')
colnames(my_array[,,2]) <- c('C1', 'C2', 'C3', 'C4', 'C5')
colnames(my_array[,,3]) <- c('C1', 'C2', 'C3', 'C4', 'C5')

dimnames(my_array)[[3]] <- c('T1', 'T2', 'T3')

my_array



X <- c(1, 1, 1)
Y <- c(2, 2, 2)
temp <- c(14.7, 18.5, 25.9)
RH <- c(66, 73, 41)
wind <- c(2.7, 8.5, 3.6)
rain <- c(0, 0, 0)
area <- c(0, 0, 0)
rank <- c(1, 2, 3)

my_matrix <- cbind(X, Y, temp, RH, wind, rain, area, rank)
print(my_matrix)


e <- c(1:10)
matrix_e_2rows <- matrix(e, nrow = 2)
print(matrix_e_2rows)


test <- function() {
  sampled_numbers <- sample(20:50, 3, replace = TRUE)

  max_value <- max(sampled_numbers)
  min_value <- min(sampled_numbers)

  mean_value <- (max_value + min_value) / 2

  return(list(sampled_numbers = sampled_numbers, max_value = max_value, min_value = min_value,mean_value = mean_value))
}

lst <- test()

print(lst)

sum_from_1_to_n <- function(n) {
  result <- sum(1:n)
  return(result)
}


print(sum_from_1_to_n(10))


result <- sqrt(log(10, base = 2))

rounded_result <- round(result, digits = 3)

print(rounded_result)


vec1 <- c(1, 2, 4)
vec2 <- c(5, 0, -1)

addition_result <- vec1 + vec2
print(addition_result)

subtraction_result <- vec1 - vec2
print(subtraction_result)

multiplication_result <- vec1 * vec2
print(multiplication_result)

division_result <- vec1 / vec2
print(division_result)

y <- c(1, 3, 5, 7, 9)
vector_length <- length(y)
print(vector_length)


a = 123.4
is_numeric_result <- is.numeric(a)
is_integer_result <- is.integer(a)
is_character_result <- is.character(a)
is_logical_result <- is.logical(a)


x <- c(1, 2, 3)
is_vector_result <- is.vector(x)

vec <- seq(from = 1.1, to = 2, length.out = 10)
vec



vec <- c(1, 2, 3, 11, 12, 13)
my_matrix <- matrix(vec, nrow = 2, ncol = 3)
rownames(my_matrix) <- c("row1", "row2")
colnames(my_matrix) <- c("C.1", "C.2", "C.3")
